package com.bw.controller;

import com.bw.bean.Vo;
import com.bw.bean.Vo2;
import com.bw.service.InfoService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
public class Controller {
    @Autowired
    InfoService infoService;
    @GetMapping("/findinfo")
    public List<Map<String,Object>> findinfo() {
        List<Map<String, Object>> findinfo = infoService.findinfo();
        for (Map<String, Object> stringObjectMap : findinfo) {
            System.out.println(stringObjectMap);
        }
        return findinfo;
    }
    @GetMapping("/find1")
    public List<Map<String,Object>> find1() {
        List<Map<String, Object>> infoService1 = infoService.find1();
        return infoService1;
    }
    @RequestMapping("/find2")
    public Map find2() {
        List<Vo> infoService2 = infoService.find2();
        ArrayList<String> list = new ArrayList<>();
        list.add("来源名称");
        list.add("订单总额");
        list.add("下单用户总数");
        list.add("订单总数");
        return SugarUtil.getTablePlayData(list,infoService2);
    }
    @RequestMapping("/find3")
    public Map find3() {
        Double infoService3 = infoService.find3();
        return SugarUtil.getFlipNumberData(infoService3);
    }
    @RequestMapping("/find4")
    public Map find4() {
        List<Vo2> infoService4 = infoService.find4();
        ArrayList<String> list = new ArrayList<>();
        list.add("课程名称");
        list.add("课程金额");
        return SugarUtil.getTablePlayData(list,infoService4);
    }
}
